/**
 * File name: ARFFFileBucketWriter.java Author: Willard Wang Create date: Aug
 * 23, 2013
 */
package edu.sjtu.se.prophet.io;

import java.util.List;

import edu.sjtu.se.prophet.graph.Bucket;
import edu.sjtu.se.prophet.graph.Graph;
import edu.sjtu.se.prophet.utils.GraphUtil;

/**
 * @author deathspeeder
 * 
 */
public class ARFFFileClassWriter extends AbstractARFFBucketWriter {

    public ARFFFileClassWriter() {
        outFileName = "data-class.arff";
        arffName = "classes";
    }

    //
    // /*
    // * (non-Javadoc)
    // *
    // * @see edu.sjtu.se.prophet.io.AbstractARFFFileWriter#writeData()
    // */
    // @Override
    // protected void writeData() throws IOException {
    // br.append("@DATA\n");
    // for (Graph graph : graphs) {
    // for (Bucket bucket : GraphUtil.generateClasses(graph)) {
    // if (bucket.getData().size() == 0)
    // continue;
    //
    // StringBuffer buffer = new StringBuffer();
    // for (int i = 0; i < VALID_METRICS.length; i++) {
    // buffer.append(bucket.getAverageMetric(VALID_METRICS[i]));
    // buffer.append(",");
    // }
    // buffer.append(getLevel(bucket.getSumMetric(IOCommon.BUG_COUNT)));
    //
    // br.append(buffer.toString() + " % "
    // + bucket.getData().get(0).getMetrics().get("File")
    // + "\n");
    // }
    // }
    // }

    /*
     * (non-Javadoc)
     * 
     * @see
     * edu.sjtu.se.prophet.io.AbstractARFFBucketWriter#getComment(edu.sjtu.se
     * .prophet.graph.Bucket)
     */
    @Override
    protected String getComment(Bucket bucket) {
        return bucket.getData().get(0).getMetrics().get("File").toString();
    }

    /*
     * (non-Javadoc)
     * 
     * @see
     * edu.sjtu.se.prophet.io.AbstractARFFBucketWriter#getBuckets(edu.sjtu.se
     * .prophet.graph.Graph)
     */
    @Override
    protected List<Bucket> getBuckets(Graph graph) {
        return GraphUtil.generateClasses(graph);
    }

}
